#!/bin/sh
#
#  This shell script gives you some examples how to use 
#  the simple template (stpl) system library.
#
# Here we include libinclude.sh.
. libinclude.sh

# Here we import the stpl library.
import stpl

# We define the template file where the variable
# fields (like: [KEY]) are included.
TPL_FILE='example.tpl'

# Here we define the variables VPREFIX_KEY to 
# fill the template. The default for VPREFIX is 'TPL'.
TPL_TEMP='200.9'
TPL_PRESS='1.0'
TPL_TYP='NVE'
TPL_SW0='# (to comment out) '
TPL_SW1=''

echo
echo " the TPL_FILE:"
echo "==============="
cat $TPL_FILE

# Example 1: 
echo
echo " the 'filled' TPL_FILE:"
echo "========================"
stpl_fill $TPL_FILE

# Example 2: 
echo
echo " the result of the check:"
echo "=========================="
stpl_check $TPL_FILE

# Example 3: 
echo
echo " the output of stpl_show:"
echo "=========================="
stpl_show $TPL_FILE

# Example 4:
echo
echo " save data, re-read, modify & output it:"
echo "========================================="
# write  template data to file
stpl_data $TPL_FILE > example_data.sh
# use libinclude to import data with a different prefix
import example_data as TPL2
# do some changes
TPL2_SW1='# (now this) '
TPL2_SW0=''
TPL2_TYP='NVT'
# output...
stpl_fill $TPL_FILE TPL2
rm example_data.sh
